package com.example.note.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.note.database.ReminderEntity;
import com.example.note.repository.ReminderRepository;

import java.util.List;

public class ReminderViewModel extends AndroidViewModel {
    
    private ReminderRepository repository;
    private LiveData<List<ReminderEntity>> allReminders;
    
    public ReminderViewModel(@NonNull Application application) {
        super(application);
        repository = new ReminderRepository(application);
        allReminders = repository.getAllReminders();
    }
    
    public LiveData<List<ReminderEntity>> getAllReminders() {
        return allReminders;
    }
    
    public LiveData<ReminderEntity> getReminderById(int id) {
        return repository.getReminderById(id);
    }
    
    public LiveData<List<ReminderEntity>> getActiveReminders() {
        return repository.getActiveReminders();
    }
    
    public LiveData<List<ReminderEntity>> getCompletedReminders() {
        return repository.getCompletedReminders();
    }
    
    public LiveData<Integer> getActiveReminderCount() {
        return repository.getActiveReminderCount();
    }
    
    public void insert(ReminderEntity reminder) {
        repository.insertReminder(reminder);
    }
    
    public void update(ReminderEntity reminder) {
        repository.updateReminder(reminder);
    }
    
    public void delete(ReminderEntity reminder) {
        repository.deleteReminder(reminder);
    }
    
    public void deleteById(int id) {
        repository.deleteReminderById(id);
    }
    
    public void markAsCompleted(int id) {
        repository.markReminderAsCompleted(id);
    }
    
    public List<ReminderEntity> getDueReminders(long currentTime) {
        return repository.getDueReminders(currentTime);
    }
}